<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- 引入外部头文件 -->
    <include file="layout/header" />
    <!-- 当前文件定制 -->
    <link rel="stylesheet" href="__PUBLIC__/tag/jquery.tag-editor.css">
    <!-- <link rel="stylesheet" href="__PUBLIC__/plugins/datatables/select.bootstrap.min.css"> -->
    <!-- ／定制结束 -->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body class="hold-transition skin-blue sidebar-mini ">
    <div class="wrapper">
        <!-- 菜单 -->
        <include file="layout/menu" name="超级管理员" />
        <!-- ／导航菜单 -->
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>会员管理<small>规则管理</small></h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li><a href="#">管理</a></li>
                    <li class="active">会员</li>
                </ol>
            </section>
            <!-- Main content -->
            <section class="content">
                <div class="row">
                    <div class="col-md-12">
                        <form id="form" action="__APP__/Home/superuser/user/viprule" method="post">
                            <div class="box">
                                <div class="box-header">
                                    <h3 class="box-title">会员规则</h3>
                                </div>
                                <!-- /.box-header -->
                                <div class="box-body no-padding">
                                    <table class="table table-striped">
                                        <tr>
                                            <th style="width: 20%">等级</th>
                                            <th style="width: 30%">消费区间</th>
                                            <th style="width: 30%">优惠幅度</th>
                                            <th style="width: 10％">操作</th>
                                        </tr>
                                        <if condition="isset($list) neq 0">
                                            <volist name="list" id="vo">
                                                <tr class="type">
                                                    <td>
                                                        <input name="rulename[]" class="form-control input-sm" type='text' placeholder="等级名" value="{$vo.rulename}" />
                                                    </td>
                                                    <td>
                                                        <span class="col-xs-5">
                                                        <input name="begin[]" class="form-control input-sm"  type='text' placeholder="" value="{$vo.begin}" />
                                                    </span> <span class="col-xs-2">-</span>
                                                        <span class="col-xs-5">
                                                        <input name="end[]" class="form-control input-sm col-xs-4" type='text' placeholder="" value="{$vo.end}" /></span>
                                                    </td>
                                                    <td><span class="col-xs-8">
                                                        <input name="discount[]"  type='text' class="form-control input-sm col-xs-8" placeholder="优惠幅度" value="{$vo.discount}" /></span><span class="col-xs-2">%</span></td>
                                                    <td>
                                                        <button class="itemdel btn btn-danger btn-xs "><i class="glyphicon glyphicon-trash"></i></button>
                                                    </td>
                                                </tr>
                                            </volist>
                                            <else />
                                            <tr class="type">
                                                <<td>
                                                    <input name="rulename[]" class="form-control input-sm" type='text' placeholder="等级名" value="" />
                                                    </td>
                                                    <td>
                                                        <span class="col-xs-5">
                                                        <input name="begin[]" class="form-control input-sm"  type='text' placeholder="" value="" />
                                                    </span> <span class="col-xs-2">-</span>
                                                        <span class="col-xs-5">
                                                        <input name="end[]" class="form-control input-sm col-xs-4" type='text' placeholder="" value="" /></span>
                                                    </td>
                                                    <td><span class="col-xs-8">
                                                        <input name="discount[]"  type='text' class="form-control input-sm col-xs-8" placeholder="优惠幅度" value="" /></span><span class="col-xs-2">%</span></td>
                                                    <td>
                                                        <button class="itemdel btn btn-danger btn-xs "><i class="glyphicon glyphicon-trash"></i></button>
                                                    </td>
                                            </tr>
                                        </if>
                                    </table>
                                </div>
                                <!-- /.box-body -->
                                <div class="box-footer text-center">
                                    <button type="button" class="pull-left btn btn-primary" id="addItem">添加规则
                                        <i class="fa fa-plus-circle"></i></button>
                                    <button type="submit" class="pull-right btn btn-default" id="submit">确认提交
                                        <i class="fa fa-arrow-circle-right"></i></button>
                                </div>
                            </div>
                            <!-- /.box-footer -->
                        </form>
                    </div>
                    <!-- /.box-body -->
                    <!-- /.box -->
                    <div class="col-md-12">
                        <div class="box">
                            <div class="box-header">
                                <h3 class="box-title">测试</h3>
                            </div>
                            <div class="box-body">
                                <div class="col-xs-4">
                                    <input type="number" id="assume" class="form-control input-sm">
                                </div>
                                <div id="show" class="row"></div>
                            </div>
                        </div>
                    </div>
            </section>
            </div>
            <!-- /.col -->
            <include file="layout/copyright" />
        </div>
        <!-- /.content-wrapper -->
        <!-- ./wrapper -->
        <!-- REQUIRED JS SCRIPTS -->
        <!-- 外头文件 -->
        <include file="layout/footer" />
        <!-- 当前定制 -->
        <script src="__PUBLIC__/tag/jquery.tag-editor.min.js"></script>
        <script src="__PUBLIC__/tag/jquery.caret.min.js"></script>
        <!-- DOM 操作 -->
        <script>
        </script>
        <!-- ./DOM -->
        <!-- AJAX -->
        <script type="text/javascript">
        $(document).ready(function() {

            //添加规格
            $('#addItem').click(function() {
                var html = '<tr class="type"><<td><input name="rulename[]" class="form-control input-sm" type="text" placeholder="等级名" value="" /></td><td><span class="col-xs-5"><input name="begin[]" class="form-control input-sm"  type="text" placeholder="" value="" /></span> <span class="col-xs-2">-</span><span class="col-xs-5"><input name="end[]" class="form-control input-sm col-xs-4" type="text" placeholder="" value="" /></span></td><td><span class="col-xs-8"><input name="discount[]"  type="text" class="form-control input-sm col-xs-8" placeholder="优惠幅度" value="" /></span><span class="col-xs-2">%</span></td><td><button class="itemdel btn btn-danger btn-xs "><i class="glyphicon glyphicon-trash"></i></button></td></tr>';
                $('.type').last().after(html);
            });

            $('body').delegate('.itemdel', 'click', function() {
                var button = $(this);
                if ($('.type').size() > 1)
                    button.parent().parent().remove();
            });

            $('#assume').change(function() {
                $.post('__APP__/Home/superuser/user/viplevel', {
                    'assume': $('#assume').val()
                }, function(data) {
                    $('#show').html(data);
                });
            })
        });
        </script>
        <!-- /AJAX -->
        <!-- ./定制结束 -->
</body>

</html>